package com.example.demo.test;

import java.util.Arrays;

/**
 * @Description TODO
 * @Author wzh
 * @Date 2022/6/8 8:29 下午
 * @Version 1.0
 */
public class Lc27 {
    public static void main(String[] args) {
        int[] nums = {3,2,2,3};
        int val = 3;
        System.out.println(removeElement(nums, val));
    }

    public static int removeElement(int[] nums, int val) {
        int left = 0;
        for (int i = 0; i < nums.length; i++) {
            if(nums[i] != val){
                nums[left] = nums[i];
                left++;
            }
        }
        System.out.println(Arrays.toString(nums));
        return left;
    }
}
